<template>
  <div>
    <p>账号密码登录</p>
    <p>
      <input type="text" v-model="username" />
    </p>
    <p>
      <input type="text" v-model="pwd" />
    </p>
    <p>
      <button @click="login">登录</button>
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "",
      pwd: "",
    };
  },
  mounted() {
  },
  methods: {
    login(){
      if(this.username && this.pwd){
        alert("登陆成功");
        localStorage.setItem(
          "user",
          JSON.stringify({name:this.username,pwd:this.pwd})
        )
        this.$router.push("/home")
        
      }else{
        alert("输入有误")
      }
    }

  },
};
</script>

<style lang='less' scoped>
</style>